****************************************
* YouGov Health Survey - February 2022 *
****************************************
svyset [pweight = weight]

*************************
* Independent Variables *
*************************
//age
gen age = 2022 - birthyr

recode age (18/37=1) (38/51=2) (52/64=3) (65/99=4), gen(age4)
tab age4, gen(Dage)

label var age4 "Age"
label define age4 1 "18-37" 2 "38-51" 3 "52-64" 4 "65+"
label values age4 age4

//race
tab race, gen(r_)
rename r_1 r_white
rename r_2 r_black
rename r_3 r_hispanic
gen r_other=r_4+r_5+r_6+r_7+r_8
label var r_white "White"
label var r_black "Black"
label var r_hispanic "Hispanic"
label var r_other "Other Race"

gen race3 = 1 if r_white == 1
replace race3 = 2 if r_black == 1
replace race3 = 3 if r_hispanic == 1

label define race3 1 "White" 2 "Black" 3 "Hispanic"
label values race3 race3 

//health status
gen healthStatus = Q5-1
label define healthStatus 0 "Poor" 1 "Fair" 2 "Good" 3 "Very good" 4 "Excellent"
label values healthStatus healthStatus 

//have child
gen haveChild = 2 - child18

//education
recode educ (1 2=1) (3 4=2) (5 6=3) (*=.), gen(educ3)
tab educ3, gen(Deduc)
label var educ3 "Education (3-categories)"
label define educ3 1 "Low" 2 "Medium" 3 "High"
label values educ3 educ3

//relationship status
gen single  = 1 if marstat == 2 | marstat == 3 | marstat == 4 | marstat == 5
replace single = 0 if marstat == 1 | marstat == 6

//has a job (1) vs. not (0)
gen working = 1 if employ == 1 | employ == 2
replace working = 0 if employ > 2

//income (80 prefer not to say)
gen income = faminc_new if faminc_new < 97

recode income (1 2 3 4 = 1) (5 6 7 8 9 = 2) (10 11 12 13 14 15 16= 3), gen(income3)
tab income3, gen(Dincome)

label var income3 "Income"
label define income3 1 "Low" 2 "Medium" 3 "High"
label values income3 income3

//vaccination status
gen vaccinated = 1 if Q21 < 5
replace vaccinated = 0 if Q21 == 5

//insurance status
recode Q4 (1 2 3 = 1) (4 = 0) (5 = .),gen(insured)


//voted in 2020
gen voted2020 = 1 if presvote20post < 6
replace voted2020 = 0 if presvote20post == 6

//Party ID 3
gen partyID_3 = 1 if pid3 == 1
replace partyID_3 = 2 if pid3 == 2
replace partyID_3 = 3 if pid3 > 2

label define partyID_3 1 "Democrat" 2 "Republican" 3 "Independent"
label values partyID_3 partyID_3

//Party ID 7
gen partyID_7 = pid7
replace partyID_7 = 4 if partyID_7 > 7
recode partyID_7 (1=-3) (2=-2) (3=-1) (4 8=0) (5=1) (6=2) (7=3)

label define partyID_7 -3 "Strong Democrat" -2 "Not very strong Democrat" -1 "Lean Democrat" 0 "Independent" 1 "Lean Republican " 2 "Not very strong Republican " 3 "Strong Republican"
label values partyID_7 partyID_7 

//Ideology
recode ideo5 (1=-2) (2=-1) (3 6=0) (4=1) (5=2) (*=.), gen(ideol)
label define ideol -2 "Very liberal" -1 "Liberal" 0 "Moderate" 1 "Conservative" 2 "Very conservative"
label values ideol ideol

//Political interest
recode newsint (1=4) (2=3) (3=2) (4=1) (*=.), gen(interest)
label var interest "Political Interest"
label define interest 1 "Hardly at all" 2 "Only now and then" 3 "Some of the time" 4 "Most of the time"
label values interest interest

recode interest (1 2=1) (3=2) (4=3) (4=1) (*=.), gen(interest3)
tab interest, gen(Dinterest)


***********************
* Dependent Variables * 
***********************
//against guidelines (1 = Not at all convicing; 4 = Very convincing)
egen against = rmean (Q17_aga_1 Q17_aga_2 Q17_aga_3 Q17_aga_4 Q17_aga_5)
replace against = 5 - against

label define against 1 "Not at all convincing" 4 "Very convincing"
label values against against

egen favor = rmean (Q17_for_1 Q17_for_2 Q17_for_3 Q17_for_4)
replace favor = 5 - favor

label values favor against

//support for CER
gen cer = (Q14-1)/4

label define cer 0 "Strongly oppose" 1 "Strongly support"
label values cer cer

//confidence in scientists' competence
gen competence = 5-Q6

gen highComp = 1 if Q6 < 3
replace highComp = 0 if Q6 > 2

gen veryComp = 1 if Q6 == 1
replace veryComp = 0 if Q6 > 1

//confidence in scientists' advice
gen advice = 5-Q7

gen highadvice = 1 if Q7 < 3
replace highadvice = 0 if Q7 > 2

gen veryadvice = 1 if Q7 == 1
replace veryadvice = 0 if Q7 > 1

//4 = A great deal of confidence; 1 = no confidence at all
egen confidence = rmean (Q6 Q7)
replace confidence = 5 - confidence



//policymakers should follow advice
gen follow = 6-Q8

gen highfollow = 1 if Q8 < 3
replace highfollow = 0 if Q8 > 2

gen veryfollow = 1 if Q8 == 1
replace veryfollow = 0 if Q8 > 1

//church attendance
gen attend = pew_churatd if pew_churatd < 7
replace attend = 7-attend
label define attend 1 "Never" 2 "Seldom" 3 "A few times a year" 4 "Once or twice a month" 5 "Once a week" 6 "More than once a week"
label values attend attend

//for, very/somewhat
recode Q17_for_1 (1 2 = 1) (3 4 = 0), gen(Q17_for_1HL)
label var Q17_for_1HL "Q17_for_1HL) Low-High"

recode Q17_for_2 (1 2 = 1) (3 4 = 0), gen(Q17_for_2HL)
label var Q17_for_2HL "Q17_for_2HL) Low-High"

recode Q17_for_3 (1 2 = 1) (3 4 = 0), gen(Q17_for_3HL)
label var Q17_for_3HL "Q17_for_3HL) Low-High"

recode Q17_for_4 (1 2 = 1) (3 4 = 0), gen(Q17_for_4HL)
label var Q17_for_4HL "Q17_for_4HL) Low-High"

//for, very
recode Q17_for_1 (1 = 1) (2 3 4 = 0), gen(Q17_for_1H)
label var Q17_for_1H "Q17_for_1H) Low-High"

recode Q17_for_2 (1 = 1) (2 3 4 = 0), gen(Q17_for_2H)
label var Q17_for_2H "Q17_for_2H) Low-High"

recode Q17_for_3 (1 = 1) (2 3 4 = 0), gen(Q17_for_3H)
label var Q17_for_3H "Q17_for_3H) Low-High"

recode Q17_for_4 (1 = 1) (2 3 4 = 0), gen(Q17_for_4H)
label var Q17_for_4H "Q17_for_4H) Low-High"

//against, very/somewhat
recode Q17_aga_1 (1 2 = 1) (3 4 = 0), gen(Q17_aga_1HL)
label var Q17_aga_1HL "Q17_aga_1HL) Low-High"

recode Q17_aga_2 (1 2 = 1) (3 4 = 0), gen(Q17_aga_2HL)
label var Q17_aga_2HL "Q17_aga_2HL) Low-High"

recode Q17_aga_3 (1 2 = 1) (3 4 = 0), gen(Q17_aga_3HL)
label var Q17_aga_3HL "Q17_aga_1HL) Low-High"

recode Q17_aga_4 (1 2 = 1) (3 4 = 0), gen(Q17_aga_4HL)
label var Q17_aga_4HL "Q17_aga_1HL) Low-High"

recode Q17_aga_5 (1 2 = 1) (3 4 = 0), gen(Q17_aga_5HL)
label var Q17_aga_5HL "Q17_aga_1HL) Low-High"

//against, very
recode Q17_aga_1 (1 = 1) (2 3 4 = 0), gen(Q17_aga_1H)
label var Q17_aga_1H "Q17_aga_1H) Low-High"

recode Q17_aga_2 (1 = 1) (2 3 4 = 0), gen(Q17_aga_2H)
label var Q17_aga_2H "Q17_aga_2H) Low-High"

recode Q17_aga_3 (1 = 1) (2 3 4 = 0), gen(Q17_aga_3H)
label var Q17_aga_3H "Q17_aga_3H) Low-High"

recode Q17_aga_4 (1 = 1) (2 3 4 = 0), gen(Q17_aga_4H)
label var Q17_aga_4H "Q17_aga_4H) Low-High"

recode Q17_aga_5 (1 = 1) (2 3 4 = 0), gen(Q17_aga_5H)
label var Q17_aga_5H "Q17_aga_5H) Low-High"

//Covid-19 impacted trust in doctors
recode Q11 (2=-1)(3=0)(1=1),gen(md_covid)
label define md_covid -1 "Decreased Trust" 0 "Trust Remained the Same" 1 "Increased Trust"
label values md_covid md_covid

//performance of healthcare actors

//MDs
recode Q12_1 (1 2 = 1) (3 4 5= 0), gen(Q12_1HL)
label var Q12_1HL "Q12_1HL) Low-High"

recode Q12_1 (5=0) (4=1) (3=2) (2=3) (1=4), gen(doctors)
label var doctor "MD rating: 0(Poor)-4(Excellent)"
label values doctor healthStatus

//Nurses
recode Q12_2 (1 2 = 1) (3 4 5= 0), gen(Q12_2HL)
label var Q12_2HL "Q12_2HL) Low-High"

//Medical research scientists
recode Q12_3 (1 2 = 1) (3 4 5= 0), gen(Q12_3HL)
label var Q12_3HL "Q12_3HL) Low-High"

//Pharmaceutical companies
recode Q12_4 (1 2 = 1) (3 4 5= 0), gen(Q12_4HL)
label var Q12_4HL "Q12_4HL) Low-High"

//Health insurance companies
recode Q12_5 (1 2 = 1) (3 4 5= 0), gen(Q12_5HL)
label var Q12_5HL "Q12_5HL) Low-High"

//FDA
recode Q12_6 (1 2 = 1) (3 4 5= 0), gen(Q12_6HL)
label var Q12_6HL "Q12_6HL) Low-High"

//CDC
recode Q12_7 (1 2 = 1) (3 4 5= 0), gen(Q12_7HL)
label var Q12_7HL "Q12_7HL) Low-High"

//State Public Health Agency
recode Q12_8 (1 2 = 1) (3 4 5= 0), gen(Q12_8HL)
label var Q12_8HL "Q12_8HL) Low-High"


//Medicare decision: aware
recode Q18 (1 2 = 1) (3 = 0), gen(aware)
label var aware "1=aware; 0=unaware"

//categorical variable (from "Not at all" to "Very aware"
gen medicare_aware = 3 - Q18
label define medicare_aware 0 "Not at all" 1 "Have just heard about it" 2 "Very aware"
label values medicare_aware medicare_aware

//Medicare decision: benefit
recode Q19 (1 2 = 1) (3 4 5= 0), gen(benefit)
label var benefit "1=Strongly/Somewhat agree; 0=Rest"

//categorical variable (from strongly disagree to strongly agree)
gen medicare_benefit = 5-Q19
label define medicare_benefit 0 "Strongly disagree" 1 "Somewhat disagree" 2 "Neither agree nor disagree" 3 "Somewhat agree" 4 "Strongly agree"
label values medicare_benefit medicare_benefit


//Medicare decision: price
recode Q20 (1 2 = 1) (3 4 5= 0), gen(price)
label var price "1=Strongly/Somewhat agree; 0=Rest"

//categorical variable (from strongly disagree to strongly agree)
gen medicare_price = 5-Q20
label values medicare_price medicare_benefit

//Familiarity with FDA
recode Q16_1 (1 = 0) (2 3 4 5 = 1), gen (fda)
label var fda "0=Not familiar at all; 1=at least slightly familiar"

//Familiarity with CDC
recode Q16_2 (1 = 0) (2 3 4 5 = 1), gen (cdc)
label var cdc "0=Not familiar at all; 1=at least slightly familiar"

//Familiarity with PCORI
recode Q16_3 (1 = 0) (2 3 4 5 = 1), gen (pcori)
label var pcori "0=Not familiar at all; 1=at least slightly familiar"

//Expensive procedures
recode Q13_1 (1 2 = 1) (3 4 = 0), gen(expensive)
label var expensive "1=Strongly/Somewhat agree; 0=Disagree"

//Innovations
recode Q13_2 (1 2 = 1) (3 4 = 0), gen(innovations)
label var innovations "1=Strongly/Somewhat agree; 0=Disagree"

//chose expensive
recode Q13_3 (1 2 = 1) (3 4 = 0), gen(chooseExpensive)
label var chooseExpensive "1=Strongly/Somewhat agree; 0=Disagree"

//Pharmaceutical companies keep profits
recode Q13_4 (1 2 = 1) (3 4 = 0), gen(profit)
label var profit "1=Strongly/Somewhat agree; 0=Disagree"

//Modern medicine and the rich
recode Q13_5 (1 2 = 1) (3 4 = 0), gen(medicine)
label var medicine "1=Strongly/Somewhat agree; 0=Disagree"

//Studies contradict each other
recode Q13_6 (1 2 = 1) (3 4 = 0), gen(contradict)
label var contradict "1=Strongly/Somewhat agree; 0=Disagree"

//doctor knows
recode Q13_7 (1 2 = 1) (3 4 = 0), gen(docKnows)
label var docKnows "1=Strongly/Somewhat agree; 0=Disagree"


recode Q15_1 (1 2 = 0) (3 = 2) (4 5 = 1), gen(Q15_1_so)
label var Q15_1_so "1=Support; 0=Oppose; 2 =Neither"

recode Q15_2 (1 2 = 0) (3 = 2) (4 5 = 1), gen(Q15_2_so)
label var Q15_2_so "1=Support; 0=Oppose 2 =Neither"

recode Q15_3 (1 2 = 0) (3 = 2) (4 5 = 1), gen(Q15_3_so)
label var Q15_3_so "1=Support; 0=Oppose 2 =Neither"

recode Q15_4 (1 2 = 0) (3 = 2) (4 5 = 1), gen(Q15_4_so)
label var Q15_4_so "1=Support; 0=Oppose 2 =Neither"

recode Q15_5 (1 2 = 0) (3 = 2) (4 5 = 1), gen(Q15_5_so)
label var Q15_5_so "1=Support; 0=Oppose 2 =Neither"

recode Q15_6 (1 2 = 0) (3 = 2) (4 5 = 1), gen(Q15_6_so)
label var Q15_6_so "1=Support; 0=Oppose 2 =Neither"

recode Q15_7 (1 2 = 0) (3 = 2) (4 5 = 1), gen(Q15_7_so)
label var Q15_7_so "1=Support; 0=Oppose 2 =Neither"

** Translating CER to Policy Indices
egen cer_trans_info = rmean(Q15_1 Q15_2) 
egen cer_trans_coverage = rmean(Q15_3 Q15_4)
egen cer_trans_allocation = rmean(Q15_5 Q15_6)
gen cer_trans_copay = Q15_7

label var cer_trans_info "Support CER to provide consumer information"
label var cer_trans_coverage "Support CER to make coverage decisions"
label var cer_trans_allocation "Support CER to allocate government resources"
label var cer_trans_copay "Support CER to raise charges or copayments"

label define cer_trans 1 "Strongly oppose" 5 "Strongly support"
label values cer_trans_info cer_trans
label values cer_trans_coverage cer_trans
label values cer_trans_allocation cer_trans
label values cer_trans_copay cer_trans
